package com.zr.d_c.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zr.d_c.service.BuyCartService;
import com.zr.d_c.serviceimpl.BuyCartServiceImpl;
/**
 * 删除购物车中的菜品
 * @author Administrator
 *
 */
public class DeleteBuyCartController extends HttpServlet {

	BuyCartService buycartservice = new BuyCartServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		PrintWriter pw = resp.getWriter();
		String bidstr = req.getParameter("bids");
		String[] bidst = bidstr.split(",");
		int[] bids = new int[bidst.length];
		for (int i = 0; i < bidst.length; i++) {
			bids[i] = Integer.parseInt(bidst[i]);
		}
		if(buycartservice.deleteBuyCartByBid(bids)>0){
			pw.write("1");
		}else{
			pw.write("0");
		}
		pw.close();
	}
}
